#pragma once
#include"Box2D/Dynamics/b2ContactManager.h"
#include"Box2D/Dynamics/Contacts/b2Contact.h"
#include"Box2D/Dynamics/b2WorldCallbacks.h"
#include<vector>
#include<string>

class OneWayWall;
class b2Body;
struct b2Vec2;

class OneWallWayContactsListener:public b2ContactListener
{
public:
	friend class OneWayWall;
	
	OneWallWayContactsListener(OneWayWall* app);
	
	~OneWallWayContactsListener();

	virtual void BeginContact(b2Contact* contact);
	
	virtual void EndContact(b2Contact* contact);
	
	virtual void PreSolve(b2Contact* contact, const b2Manifold* oldManifold);
private:
	void isContactWithPlatfrom(b2Contact* contact, b2Body* plat, bool isBeginConatct);

	void issContactWithGround(b2Contact* conatct, b2Body* ground, bool isBeginContact);
	
	std::vector<b2Body*> sortByOneBody(b2Contact* contact, std::string targetA);

	b2Vec2 getContactsaPoint(b2Contact* contact);

	OneWayWall * app;
	b2Body* tempBodyA;
	b2Body* tempBodyB;
	b2Body* palyer;
	b2Body* another;
	bool isPlayerOnGround = true;
};